package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Image      string  `gorm:"type:varchar(255);comment:'商品图片'"`
	GoodsName  string  `gorm:"type:varchar(30);comment:'商品名称'"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);comment:'价格'"`
	Stock      int64   `gorm:"type:int(5);comment:'库存'"`
	ShopId     int64   `gorm:"type:int(5);comment:'商家Id'"`
	Status     string  `gorm:"type:varchar(30);comment:'状态'"`
}

func (g *Goods) GetGoodsById() error {
	return DB.Where("id=?", g.ID).Limit(1).Find(g).Error
}

func (g *Goods) CreateGoods() error {
	return DB.Create(&g).Error
}
